/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package uimigration.widgetscorrepondances.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import uimigration.UIModel.UIElement;
import uimigration.widgetscorrepondances.Equivalents;
import uimigration.widgetscorrepondances.FUIElement;
import uimigration.widgetscorrepondances.WidgetscorrepondancesPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>FUI Element</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link uimigration.widgetscorrepondances.impl.FUIElementImpl#getWidgetType <em>Widget Type</em>}</li>
 *   <li>{@link uimigration.widgetscorrepondances.impl.FUIElementImpl#getName <em>Name</em>}</li>
 *   <li>{@link uimigration.widgetscorrepondances.impl.FUIElementImpl#getWidgets <em>Widgets</em>}</li>
 *   <li>{@link uimigration.widgetscorrepondances.impl.FUIElementImpl#getUielement <em>Uielement</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class FUIElementImpl extends EObjectImpl implements FUIElement {
	/**
	 * The default value of the '{@link #getWidgetType() <em>Widget Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getWidgetType()
	 * @generated
	 * @ordered
	 */
	protected static final String WIDGET_TYPE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getWidgetType() <em>Widget Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getWidgetType()
	 * @generated
	 * @ordered
	 */
	protected String widgetType = WIDGET_TYPE_EDEFAULT;

	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * The cached value of the '{@link #getWidgets() <em>Widgets</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getWidgets()
	 * @generated
	 * @ordered
	 */
	protected EList<Equivalents> widgets;

	/**
	 * The cached value of the '{@link #getUielement() <em>Uielement</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getUielement()
	 * @generated
	 * @ordered
	 */
	protected UIElement uielement;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected FUIElementImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return WidgetscorrepondancesPackage.Literals.FUI_ELEMENT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getWidgetType() {
		return widgetType;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setWidgetType(String newWidgetType) {
		String oldWidgetType = widgetType;
		widgetType = newWidgetType;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WidgetscorrepondancesPackage.FUI_ELEMENT__WIDGET_TYPE, oldWidgetType, widgetType));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WidgetscorrepondancesPackage.FUI_ELEMENT__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Equivalents> getWidgets() {
		if (widgets == null) {
			widgets = new EObjectContainmentEList<Equivalents>(Equivalents.class, this, WidgetscorrepondancesPackage.FUI_ELEMENT__WIDGETS);
		}
		return widgets;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public UIElement getUielement() {
		return uielement;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetUielement(UIElement newUielement, NotificationChain msgs) {
		UIElement oldUielement = uielement;
		uielement = newUielement;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, WidgetscorrepondancesPackage.FUI_ELEMENT__UIELEMENT, oldUielement, newUielement);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setUielement(UIElement newUielement) {
		if (newUielement != uielement) {
			NotificationChain msgs = null;
			if (uielement != null)
				msgs = ((InternalEObject)uielement).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - WidgetscorrepondancesPackage.FUI_ELEMENT__UIELEMENT, null, msgs);
			if (newUielement != null)
				msgs = ((InternalEObject)newUielement).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - WidgetscorrepondancesPackage.FUI_ELEMENT__UIELEMENT, null, msgs);
			msgs = basicSetUielement(newUielement, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WidgetscorrepondancesPackage.FUI_ELEMENT__UIELEMENT, newUielement, newUielement));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case WidgetscorrepondancesPackage.FUI_ELEMENT__WIDGETS:
				return ((InternalEList<?>)getWidgets()).basicRemove(otherEnd, msgs);
			case WidgetscorrepondancesPackage.FUI_ELEMENT__UIELEMENT:
				return basicSetUielement(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case WidgetscorrepondancesPackage.FUI_ELEMENT__WIDGET_TYPE:
				return getWidgetType();
			case WidgetscorrepondancesPackage.FUI_ELEMENT__NAME:
				return getName();
			case WidgetscorrepondancesPackage.FUI_ELEMENT__WIDGETS:
				return getWidgets();
			case WidgetscorrepondancesPackage.FUI_ELEMENT__UIELEMENT:
				return getUielement();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case WidgetscorrepondancesPackage.FUI_ELEMENT__WIDGET_TYPE:
				setWidgetType((String)newValue);
				return;
			case WidgetscorrepondancesPackage.FUI_ELEMENT__NAME:
				setName((String)newValue);
				return;
			case WidgetscorrepondancesPackage.FUI_ELEMENT__WIDGETS:
				getWidgets().clear();
				getWidgets().addAll((Collection<? extends Equivalents>)newValue);
				return;
			case WidgetscorrepondancesPackage.FUI_ELEMENT__UIELEMENT:
				setUielement((UIElement)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case WidgetscorrepondancesPackage.FUI_ELEMENT__WIDGET_TYPE:
				setWidgetType(WIDGET_TYPE_EDEFAULT);
				return;
			case WidgetscorrepondancesPackage.FUI_ELEMENT__NAME:
				setName(NAME_EDEFAULT);
				return;
			case WidgetscorrepondancesPackage.FUI_ELEMENT__WIDGETS:
				getWidgets().clear();
				return;
			case WidgetscorrepondancesPackage.FUI_ELEMENT__UIELEMENT:
				setUielement((UIElement)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case WidgetscorrepondancesPackage.FUI_ELEMENT__WIDGET_TYPE:
				return WIDGET_TYPE_EDEFAULT == null ? widgetType != null : !WIDGET_TYPE_EDEFAULT.equals(widgetType);
			case WidgetscorrepondancesPackage.FUI_ELEMENT__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case WidgetscorrepondancesPackage.FUI_ELEMENT__WIDGETS:
				return widgets != null && !widgets.isEmpty();
			case WidgetscorrepondancesPackage.FUI_ELEMENT__UIELEMENT:
				return uielement != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (widgetType: ");
		result.append(widgetType);
		result.append(", name: ");
		result.append(name);
		result.append(')');
		return result.toString();
	}

} //FUIElementImpl
